// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/parking/api/ParkRecordApi'

import ComClass from '@api/ComQuery'

import ListClass from '@api/parking/model/ParkRecordListQueryReq'
import InOutClass from '@api/parking/model/CountRecordByTimeReq'

const ResultClass = InOutClass
const TypeClass = InOutClass

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '[停车管理] 查询通行记录') {
    const DTO = CORE.grpcDTO(ListClass, param, COM)
    const { comQuery, parkRecordDto } = await CORE.grpc(TIP, CLIENT, 'queryParkRecordList', DTO)
    return [comQuery.totalCount, parkRecordDto]
  },

  // —————————————————————————————— 进出统计 —————————————————————————————— //

  async getInOut({ dateType }, TIP = '[停车管理] 查询进出统计') {
    const DTO = CORE.grpcDTO(InOutClass, { dateType })
    const { content, xData } = await CORE.grpc(TIP, CLIENT, 'countRecordByTime', DTO)
    return { content, xData }
  },

  // —————————————————————————————— 放行结果 —————————————————————————————— //

  async getResult({ dateType }, TIP = '[停车管理] 查询放行结果') {
    const DTO = CORE.grpcDTO(ResultClass, { dateType })
    const { content } = await CORE.grpc(TIP, CLIENT, 'countRecordByType', DTO)
    return content
  },

  // —————————————————————————————— 放行方式 —————————————————————————————— //

  async getType({ dateType }, TIP = '[停车管理] 查询放行方式') {
    const DTO = CORE.grpcDTO(TypeClass, { dateType })
    const { content } = await CORE.grpc(TIP, CLIENT, 'countRecordByType', DTO)
    return content
  },
}
